/*
 * Copyright (c) 2003-2005
 * XDoclet Team
 * All rights reserved.
 */
package org.xdoclet.plugin.hibernate;

import org.generama.JellyTemplateEngine;
import org.generama.QDoxCapableMetadataProvider;
import org.generama.WriterMapper;
import org.generama.defaults.QDoxPlugin;

/**
 * @author Anatol Pomozov
 */
public abstract class AbstractHibernatePlugin extends QDoxPlugin {
    private String version = HibernateVersion.HIBERNATE_2_0;

    public AbstractHibernatePlugin(JellyTemplateEngine jellyTemplateEngine,
        QDoxCapableMetadataProvider metadataProvider, WriterMapper writerMapper) {
        super(jellyTemplateEngine, metadataProvider, writerMapper);
    }

    public String getDTDVersion() {
        return version;
    }

    /**
     * Specify version of Hibernate.
     * @generama.property required="false" default="2.0" allowed-values="2.0, 3.0"
     */
    public void setVersion(String version) {
        String[] values = HibernateVersion.getValues();

        for (int i = 0; i < values.length; i++) {
            if (values[i].equals(version)) {
                this.version = version;
                return;
            }
        }

        throw new IllegalArgumentException("Incorrect hibernate version : " + version);
    }
}